
var app=angular.module('registerApp',[]);
app.controller('registerCtrl',function($scope,$http){
	$scope.user ={};
	$scope.check=true;

	$scope.phoneCheck = function(num){
  	var ph =/^1[3|7|5|8]\d{9}$/;
		return ph.test(num);
	}

	$scope.addUser = function() {
		if($scope.phoneCheck($scope.user.phone)) {
			if($scope.user.password == $scope.repassword) {
				$http.post(register_url, $scope.user)
					.success(function(res){
						if(res.code==200) {
							alert('注册成功');
							location.href = "http://localhost:8080/graduation/OAsystem/login.html";
						}else {
							Notify(res.data,"top-right");
						}
					})
			}else{Notify("两次密码输入不一致","top-right");}
		}else {Notify("手机号码错误，请输入正确的手机号码","top-right");}
	}
});
